package gjw.jimven.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * sp工具类
 */
public class PreferenceUtils {

	public static void putString(Context context, String key, String value){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		sp.edit().putString(key, value).commit();
	}

	public static String getString(Context context, String key, String defValue){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		return sp.getString(key, defValue);
	}
	public static String getString(Context context, String key){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		return getString(context,key,"");
	}

	public static void putBoolean(Context context, String key, boolean value){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		sp.edit().putBoolean(key, value).commit();
	}

	public static boolean getBoolean(Context context, String key, boolean defValue){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		return sp.getBoolean(key, defValue);
	}

	public static boolean getBoolean(Context context, String key){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		return getBoolean(context,key,false);
	}

	public static void putInt(Context context, String key, int value){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		sp.edit().putInt(key, value).commit();
	}

	public static int getInt(Context context, String key, int defValue){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		return sp.getInt(key, defValue);
	}

	public static int getInt(Context context, String key){
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		return getInt(context,key,-1);
	}








	
}
